package com.xuecheng.search.controller;

import com.xuecheng.commons.model.dto.CoursePubIndexDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
public class SearchController {


    @Autowired
    private SearchService searchService;


    // 课程搜索
    @PostMapping("/course-search")
    public ResponseResult search(PageRequest params, @RequestBody CoursePubIndexDto dto) throws IOException {
        return searchService.search(params,dto);
    }


    // 根据id查询
    @GetMapping("/course-search/{id}")  // 索引库id是string类型
    public ResponseResult findById(@PathVariable("id")String id) throws IOException {
        return searchService.findById(id);
    }
}
